import { defineStore } from "pinia";
import { computed, ref } from "vue";
// 精确控制持久化数据存储
export const userCounterStore = defineStore('counter', () => {
  // 定义数据
  const count = ref(100)
  const num1 = ref(100)
  const num2 = ref(200)
  const doubleCount = computed(() => {
    return count.value * 2
  })
  // 定义操作数据的方法
  const increment = () => {
    count.value++
  }
  const decrement = ()=>{
    count.value--
  }
  return { count, decrement, increment,doubleCount,num1,num2}
},{
  // @ts-ignore  
  // unistorage: true, // 开启后对 state 的数据读写都将持久化
  unistorage: {
    key: 'cp-patient',
    paths: ['count',"num1","num2"],
  }
})